package com.ruoyi.monitor.infoprojectmonitorindex.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.evaluate.infoprojectevaluate.domain.InfoProjectEvaluate;
import com.ruoyi.monitor.infoprojectmonitorindex.domain.InfoProjectMonitorIndex;
import com.ruoyi.monitor.infoprojectmonitorindex.service.IInfoProjectMonitorIndexService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 项目监控 -指标Controller
 *
 * @author ruoyi
 * @date 2022-02-15
 */
@RestController
@RequestMapping("/infoProjectMonitorIndex/infoProjectMonitorIndex")
public class InfoProjectMonitorIndexController extends BaseController {
    @Autowired
    private IInfoProjectMonitorIndexService infoProjectMonitorIndexService;

    /**
     * 查询项目监控 -指标列表
     */
    @PreAuthorize("@ss.hasPermi('infoProjectMonitorIndex:infoProjectMonitorIndex:list')")
    @GetMapping("/list")
    public TableDataInfo list(InfoProjectMonitorIndex infoProjectMonitorIndex) {
        List<InfoProjectMonitorIndex> list = infoProjectMonitorIndexService.selectInfoProjectMonitorIndexList(infoProjectMonitorIndex);
        return getDataTable(list);
    }

    /**
     * 导出项目监控 -指标列表
     */
    @PreAuthorize("@ss.hasPermi('infoProjectMonitorIndex:infoProjectMonitorIndex:export')")
    @Log(title = "项目监控 -指标", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, InfoProjectMonitorIndex infoProjectMonitorIndex) {
        List<InfoProjectMonitorIndex> list = infoProjectMonitorIndexService.selectInfoProjectMonitorIndexList(infoProjectMonitorIndex);
        ExcelUtil<InfoProjectMonitorIndex> util = new ExcelUtil<InfoProjectMonitorIndex>(InfoProjectMonitorIndex.class);
        util.exportExcel(response, list, "项目监控 -指标数据");
    }

    /**
     * 获取项目监控 -指标详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(infoProjectMonitorIndexService.selectInfoProjectMonitorIndexById(id));
    }

    /**
     * 新增项目监控 -指标
     */
    @PreAuthorize("@ss.hasPermi('infoProjectMonitorIndex:infoProjectMonitorIndex:add')")
    @Log(title = "项目监控 -指标", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InfoProjectMonitorIndex infoProjectMonitorIndex) {
        return toAjax(infoProjectMonitorIndexService.insertInfoProjectMonitorIndex(infoProjectMonitorIndex));
    }

    /**
     * 修改项目监控 -指标
     */
    @Log(title = "项目监控 -指标", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InfoProjectMonitorIndex infoProjectMonitorIndex) {
        return toAjax(infoProjectMonitorIndexService.updateInfoProjectMonitorIndex(infoProjectMonitorIndex));
    }

    /**
     * 删除项目监控 -指标
     */
    @PreAuthorize("@ss.hasPermi('infoProjectMonitorIndex:infoProjectMonitorIndex:remove')")
    @Log(title = "项目监控 -指标", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(infoProjectMonitorIndexService.deleteInfoProjectMonitorIndexByIds(ids));
    }

    /**
     * 上传佐证
     */
    @PostMapping(value = "/uploadFiles")
    public AjaxResult uploadFiles(@RequestBody InfoProjectMonitorIndex infoProjectMonitorIndex) {
        return toAjax(infoProjectMonitorIndexService.uploadFiles(infoProjectMonitorIndex));
    }
}
